<template>
  <j-modal title="新增入组" :width="900" :visible="visible" switchFullscreen @cancel="handleCancel" @ok="handleOk">
    <a-form-model ref="ruleForm" :model="form" :rules="rules" :label-col="labelCol" :wrapper-col="wrapperCol"
      style="padding:0 0 20px 20px;">
      <a-row>
        <a-col :span="12">
          <a-form-model-item label="门诊所在地区">
            <a-select v-model="form.incidentCode" :show-search="true" :allowClear="false"
              :default-active-first-option="false" :show-arrow="false" :filter-option="false" :not-found-content="null"
              style="width: 100%" placeholder="请输入" :disabled="isDisabled" @search="onSearch" @change="onChange">
              <a-select-option v-for="(item, key) in bhLit" :key="key" :value="item.incidentId">{{
                  item.incidentCode
              }}</a-select-option>
            </a-select>
          </a-form-model-item>
        </a-col>
        <a-col :span="12">
          <a-form-model-item label="门诊名称" required prop="departName">
            <a-select v-model="form.region1" placeholder="请选择">
              <a-select-option value="0">
                定期访谈
              </a-select-option>
              <a-select-option value="1">
                日常访谈
              </a-select-option>
            </a-select>
          </a-form-model-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col :span="12">
          <a-form-model-item label="申请者号" prop="apprehendUserPhone">
            <a-input v-model="form.apprehendUserPhone" :disabled="isDisabled" placeholder="请输入"> </a-input>
          </a-form-model-item>
        </a-col>
        <a-col :span="12">
          <a-form-model-item label="病人编号" prop="apprehendUserPhone">
            <a-input v-model="form.apprehendUserPhone" :disabled="isDisabled" placeholder="请输入"> </a-input>
          </a-form-model-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col :span="12">
          <a-form-model-item label="第几次入组" prop="apprehendUserPhone">
            <a-input v-model="form.apprehendUserPhone" :disabled="isDisabled" placeholder="请输入"> </a-input>
          </a-form-model-item>
        </a-col>
        <a-col :span="12">
          <a-form-model-item label="姓名" prop="apprehendUserPhone">
            <a-input v-model="form.apprehendUserPhone" :disabled="isDisabled" placeholder="请输入"> </a-input>
          </a-form-model-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col :span="12">
          <a-form-model-item label="身份证号码" prop="apprehendUserPhone">
            <a-input v-model="form.apprehendUserPhone" :disabled="isDisabled" placeholder="请输入"> </a-input>
          </a-form-model-item>
        </a-col>
        <a-col :span="12">
          <a-form-model-item label="性别" prop="apprehendUserPhone">
            <a-select v-model="form.region1" placeholder="请选择">
              <a-select-option value="0">男</a-select-option>
              <a-select-option value="1">女</a-select-option>
            </a-select>
          </a-form-model-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col :span="12">
          <a-form-model-item label="出生日期" required prop="rangeTime">
            <a-date-picker :allowClear="true" v-model="form.rangeTime" :disabled="isDisabled" show-time
              format="YYYY-MM-DD HH:mm:ss" @change="rangePickerChange" style="width:100%" />
          </a-form-model-item>
        </a-col>
        <a-col :span="12">
          <a-form-model-item label="民族" required prop="rangeTime">
            <a-select v-model="form.region1" placeholder="请选择">
              <a-select-option value="0">汉</a-select-option>
              <a-select-option value="1">满</a-select-option>
            </a-select>
          </a-form-model-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col :span="12">
          <a-form-model-item label="婚姻状况" prop="apprehendUserPhone">
            <a-select v-model="form.region1" placeholder="请选择">
              <a-select-option v-for="(item, key) in marriageArr" :key="key" :value="item.value">{{ item.title }}
              </a-select-option>
            </a-select>
          </a-form-model-item>
        </a-col>
        <a-col :span="12">
          <a-form-model-item label="文化程度" required prop="departName">
            <a-select v-model="form.region1" placeholder="请选择">
              <a-select-option v-for="(item, key) in educationArr" :key="key" :value="item.value">{{ item.title }}
              </a-select-option>
            </a-select>
          </a-form-model-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col :span="12">
          <a-form-model-item label="从业状况" prop="apprehendUserPhone">
            <a-select v-model="form.region1" placeholder="请选择">
              <a-select-option v-for="(item, key) in employArr" :key="key" :value="item.value">{{ item.title }}
              </a-select-option>
            </a-select>
          </a-form-model-item>
        </a-col>
        <a-col :span="12">
          <a-form-model-item label="初次吸毒时间" required prop="departName">
            <a-date-picker :allowClear="true" v-model="form.rangeTime" :disabled="isDisabled" show-time
              format="YYYY-MM-DD HH:mm:ss" @change="rangePickerChange" style="width:100%" />
          </a-form-model-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col :span="12">
          <a-form-model-item label="滥用毒品方式" prop="apprehendUserPhone">
            <a-input v-model="form.apprehendUserPhone" :disabled="isDisabled" placeholder="请输入"> </a-input>
          </a-form-model-item>
        </a-col>
        <a-col :span="12">
          <a-form-model-item label="滥用毒品种类" required prop="departName">
            <a-select v-model="form.region1" placeholder="请选择">
              <a-select-option v-for="(item, key) in drugsArr" :key="key" :value="item.value">{{ item.title }}
              </a-select-option>
            </a-select>
          </a-form-model-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col :span="12">
          <a-form-model-item label="现居住地" required prop="departName">
            <a-input v-model="form.apprehendUserPhone" :disabled="isDisabled" placeholder="请输入"> </a-input>
          </a-form-model-item>
        </a-col>
        <a-col :span="12">
          <a-form-model-item label="现居住地详址" required prop="departName">
            <a-input v-model="form.apprehendUserPhone" :disabled="isDisabled" placeholder="请输入"> </a-input>
          </a-form-model-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col :span="12">
          <a-form-model-item label="户籍地" required prop="departName">
            <a-input v-model="form.apprehendUserPhone" :disabled="isDisabled" placeholder="请输入"> </a-input>
          </a-form-model-item>
        </a-col>
        <a-col :span="12">
          <a-form-model-item label="户籍地详址" required prop="departName">
            <a-input v-model="form.apprehendUserPhone" :disabled="isDisabled" placeholder="请输入"> </a-input>
          </a-form-model-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col :span="12">
          <a-form-model-item label="联系电话" required prop="departName">
            <a-input v-model="form.apprehendUserPhone" :disabled="isDisabled" placeholder="请输入"> </a-input>
          </a-form-model-item>
        </a-col>
      </a-row>
    </a-form-model>
  </j-modal>
</template>
<script>
// import * as caseApi from '@/api/wxSmuggle/caseEvent.js'
export default {
  props: ['title'],
  components: {},
  data() {
    return {
      labelCol: { span: 22 },
      wrapperCol: { span: 22 },
      marriageArr: [
        {
          title: "未婚",
          value: 0
        },
        {
          title: "已婚",
          value: 1
        },
        {
          title: "初婚",
          value: 2
        },
        {
          title: "再婚",
          value: 3
        },
        {
          title: "复婚",
          value: 4
        },
        {
          title: "丧偶",
          value: 5
        },
        {
          title: "离婚",
          value: 6
        },
        {
          title: "未说明的婚姻状况",
          value: 7
        }],
      educationArr: [
        {
          title: "小学",
          value: 0
        },
        {
          title: "初中",
          value: 1
        },
        {
          title: "高中",
          value: 2
        },
        {
          title: "中专",
          value: 3
        },
        {
          title: "大专",
          value: 4
        },
        {
          title: "本科",
          value: 5
        },
        {
          title: "本科以上",
          value: 6
        },
        {
          title: "文盲或半文盲",
          value: 7
        }],
      employArr: [
        {
          title: "国家公务员",
          value: 0
        },
        {
          title: "专业技术人员",
          value: 1
        },
        {
          title: "职员",
          value: 2
        },
        {
          title: "企业管理人员",
          value: 3
        },
        {
          title: "工人",
          value: 4
        },
        {
          title: "农民",
          value: 5
        },
        {
          title: "学生",
          value: 6
        },
        {
          title: "现役军人",
          value: 7
        },
        {
          title: "自由职业者",
          value: 8
        },
        {
          title: "个体经营者",
          value: 9
        },
        {
          title: "无业人员",
          value: 10
        },
        {
          title: "退（离）休人员",
          value: 11
        },
        {
          title: "其它",
          value: 12
        }],
      drugsArr: [
        {
          title: "海洛因",
          value: 0
        },
        {
          title: "鸦片",
          value: 1
        },
        {
          title: "大麻",
          value: 2
        },
        {
          title: "吗啡",
          value: 3
        },
        {
          title: "冰毒",
          value: 4
        },
        {
          title: "冰毒片剂",
          value: 5
        },
        {
          title: "咖啡因",
          value: 6
        },
        {
          title: "安钠咖",
          value: 7
        },
        {
          title: "氰胺酮",
          value: 8
        },
        {
          title: "安眠酮",
          value: 9
        },
        {
          title: "杜冷丁",
          value: 10
        },
        {
          title: "可卡因",
          value: 11
        },
        {
          title: "罂粟壳",
          value: 12
        },
        {
          title: "摇头丸",
          value: 13
        },
        {
          title: "其他笨丙胺类毒品",
          value: 14
        },
        {
          title: "埃托啡",
          value: 15
        },
        {
          title: "其他毒品",
          value: 16
        }],
      form: {
        incidentId: null,
        incidentCode: '',
        incidentName: '',
        departName: '',
        rangeTime: undefined,
        apprehendUser: '',
        apprehendUserPhone: '',
        description: '',
        category: 1
      },
      rules: {
        incidentName: [{ required: true, message: '请输入案事件名称' }],
        departName: [{ required: true, message: '请选择所属单位' }],
        rangeTime: [{ required: true, message: '请选择案事件日期' }],
        apprehendUser: [{ required: true, message: '请输入办案人' }],
        apprehendUserPhone: [
          { required: true, message: '请输入联系电话' },
        ],
        description: [{ required: true, message: '请输入说明' }]
      },
      isDisabled: false,
      bhLit: [],
      visible: false,
    }
  },
  created() {
    // let user = Vue.ls.get(USER_INFO)
    // this.form.apprehendUser = Vue.ls.get(USER_INFO).realname
  },
  methods: {
    show() {
      this.visible = true
    },
    onChange(val) {
      if (val != undefined) {
        caseApi.incidentDetail(val).then(res => {
          if (res.success) {
            this.form.incidentId = val
            this.form.incidentCode = res.result.incidentCode
            this.form.incidentName = res.result.incidentName
            this.form.departName = res.result.departName
            this.form.apprehendUser = res.result.apprehendUser
            this.form.apprehendUserPhone = res.result.apprehendUserPhone
            this.form.description = res.result.description
            this.form.rangeTime = [res.result.startTime, res.result.endTime]
            this.form.startTime = res.result.startTime
            this.form.endTime = res.result.endTime
            this.isDisabled = true
          }
        })
      } else {
        this.form = {
          incidentId: null,
          incidentName: '',
          departName: '',
          rangeTime: [],
          apprehendUser: '',
          apprehendUserPhone: '',
          description: ''
        }
        this.bhLit = []
      }
    },
    onSearch(val) {
      if (val == '') {
        return
      }
      caseApi.queryCodeList({ incidentCode: val, category: 1 }).then(res => {
        if (res.success) {
          this.bhLit = res.result
        }
      })
    },
    rangePickerChange(date) {
      // this.$set(this.form, 'startTime', date[0])
      // this.$set(this.form, 'endTime', date[1])
    },
    onValidate() {
      let isValid = false
      this.$refs.ruleForm.validate(valid => {
        if (valid) {
          isValid = true
        } else {
          isValid = false
        }
      })
      if (isValid) {
        return true
      } else {
        return false
      }
    },
    handleCancel() {
      this.visible = false
    },
    handleOk() {
      this.visible = false
    }
  }
}
</script>
<style scoped lang="less">
/deep/.ant-col-22 {
  text-align: left;
}

/deep/.ant-row {
  margin-bottom: 0;
}
</style>
